package com.max.eshop.services;

import com.danco.training.TextFileWorker;

public class Files {
	private final static String nameBooks = "books.txt";
	private final static String nameOrders = "orders.txt";
	private final static String nameReqests = "reqests.txt";
	TextFileWorker tfwB;
	TextFileWorker tfwO;
	TextFileWorker tfwR;

	public Files(String path) {
		tfwB = new TextFileWorker(path + nameBooks);
		tfwO = new TextFileWorker(path + nameOrders);
		tfwR = new TextFileWorker(path + nameReqests);
	}

	public void writeToFiles(String[] books, String[] orders, String[] reqests) {

		tfwR.writeToFile(reqests);
		tfwB.writeToFile(books);
		tfwO.writeToFile(orders);
	}

	public String[] readBooksFromFiles() {
		return tfwB.readFromFile();
	}

	public String[] readReqestsFromFiles() {

		return tfwR.readFromFile();

	}

	public String[] readOrdersFromFiles() {
		return tfwO.readFromFile();
	}

}
